package cn.itcast.tanhua.mytanhuaserver.service.impl;

import cn.itcast.tanhua.mytanhuadubbointerface.api.UserLocationApi;
import cn.itcast.tanhua.mytanhuaserver.service.BaiduService;
import cn.itcast.tanhua.pojo.User;
import cn.itcast.tanhua.utils.UserThreadLocal;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.log4j.Log4j;
import org.springframework.stereotype.Service;

/**
 * @author 郭文亮
 * @since 2021/12/4 15:32
 */
@Service
@Log4j
public class BaiduServiceImpl implements BaiduService {

    @Reference
    private UserLocationApi userLocationApi;

    @Override
    public Boolean updateLocation(Double longitude, Double latitude, String address) {
        User user = UserThreadLocal.get();
        try {
            return this.userLocationApi.updateUserLocation(user.getId(), longitude, latitude, address);
        } catch (Exception e) {
            log.error("更新地理位置失败~ userId = " + user.getId() + ", longitude = " + longitude + ", latitude = " + latitude + ", address = " + address, e);
        }
        return false;
    }
}
